package cc.vicp.djx314.starfood.web.test;

import net.sf.ehcache.Cache;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/refresh")
public class RefreshCacheController {
	private static final Logger logger = LoggerFactory.getLogger(RefreshCacheController.class);
	@Autowired
	private Cache cache;
	public void setCache(Cache cache) {
		this.cache = cache;
	}

	@RequestMapping(method = RequestMethod.GET)
	public String removeCache() {
		cache.removeAll();
		logger.info("清空所有缓存！");
		return "redirect:/index";
	}
}
